package cn.wolfcode.service.impl;

import cn.wolfcode.domain.MessageReplyDzq;
import cn.wolfcode.mapper.MessageReplyDzqMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMessageReplyDzqService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageReplyDzqServiceImpl implements IMessageReplyDzqService {

    @Autowired
    private MessageReplyDzqMapper messageReplyDzqMapper;


    @Override
    public void save(MessageReplyDzq messageReplyDzq) {
        messageReplyDzqMapper.insert(messageReplyDzq);
    }

    @Override
    public void delete(Long id) {
        messageReplyDzqMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(MessageReplyDzq messageReplyDzq) {
        messageReplyDzqMapper.updateByPrimaryKey(messageReplyDzq);
    }

    @Override
    public MessageReplyDzq get(Long id) {
        return messageReplyDzqMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<MessageReplyDzq> listAll() {
        return messageReplyDzqMapper.selectAll();
    }

    @Override
    public PageInfo<MessageReplyDzq> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<MessageReplyDzq> messageReplyDzqs = messageReplyDzqMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<MessageReplyDzq>(messageReplyDzqs);
    }

    @Override
    public int selectCount(Long id) {
        return messageReplyDzqMapper.selectCount(id);
    }

    @Override
    public List<MessageReplyDzq> selectContext(Long id) {
        return messageReplyDzqMapper.selectContext(id);
    }
}
